package com.gzs.learn.payment.inf.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
public enum PayChannelEnum {
	ALIYPAY(1, "alipay"),

	WECHAT(2,"wechat"),

	UNIONPAY(3,"unionpay")

	;

	private static final Map<Integer, PayChannelEnum> HOLDER_MAP = new HashMap<>();
	static {
		for (PayChannelEnum e : values()) {
			HOLDER_MAP.put(e.getCode(), e);
		}
	}

	private final int code;
	private final String desc;

	PayChannelEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public static PayChannelEnum convert(int code) {
		return HOLDER_MAP.get(code);
	}
}
